home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Sample Code / AppsToGo / AppWannabe / Window.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-22  |  21.4 KB  |  659 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** File:        Window.c
  5. ** Written by:    Eric Soldan
  6. **
  7. ** Copyright © 1990-1993 Apple Computer, Inc.
  8. ** All rights reserved.
  9. */
  10.  
  11. /* You may incorporate this sample code into your applications without
  12. ** restriction, though the sample code has been provided "AS IS" and the
  13. ** responsibility for its operation is 100% yours.  However, what you are
  14. ** not permitted to do is to redistribute the source as "DSC Sample Code"
  15. ** after having made changes. If you're going to re-distribute the source,
  16. ** we require that you make it clear in the source that the code was
  17. ** descended from Apple Sample Code, but that you've made changes. */
  18.  
  19. /* This file contains the code for the document procedure pointers for the main Wannabe
  20. ** document.  Wannabe currently only supports one type of documents, type 'DUMD',
  21. ** which stands for "DUMb Document". */
  22.  
  23. /* For more information on this file, please read the read.me file "=How to write your app". */ 
  24.  
  25.  
  26.  
  27. /*****************************************************************************/
  28.  
  29.  
  30.  
  31. #include "App.h"            /* Get the application includes/typedefs, etc.    */
  32. #include "App.defs.h"        /* Get various application definitions.            */
  33. #include "App.protos.h"        /* Get the prototypes for application.            */
  34.  
  35. #ifndef __ERRORS__
  36. #include <Errors.h>
  37. #endif
  38.  
  39. #ifndef __FONTS__
  40. #include <Fonts.h>
  41. #endif
  42.  
  43. #ifndef __RESOURCES__
  44. #include <Resources.h>
  45. #endif
  46.  
  47. #ifndef __TOOLUTILS__
  48. #include <ToolUtils.h>
  49. #endif
  50.  
  51. #ifndef __UTILITIES__
  52. #include "Utilities.h"
  53. #endif
  54.  
  55.  
  56.  
  57. /*****************************************************************************/
  58.  
  59.  
  60.  
  61. Boolean        gNoDefaultDocument = false;
  62.                     /* Set to true if app should boot with no default document. */
  63.                     /* This tells DTS.Lib..framework what you want. */
  64.  
  65. OSType        gAppWindowType = kDocFileType;    /* Main document type. */
  66. long        gAppWindowAttr = kwAppWindow;    /* Main window attributes. */
  67.  
  68. short        gMinVersion    = kMinVersion;    /* Minimum document version app can support. */
  69. short        gMaxVersion    = kMaxVersion;    /* Maximum document version app can support. */
  70.                                             /* More informing DTS.Lib..framework. */
  71.  
  72. extern short        gPrintPage;                /* Non-zero means we are printing. */
  73.                                             /* DTS.Lib..framework global. */
  74.  
  75. extern RgnHandle    gCursorRgn;                /* We handle cursors here, so we need */
  76. extern CursPtr        gCursorPtr;                /* to know about these things. */
  77.                                             /* Above are DTS.Lib..framework globals. */
  78.  
  79. /* Currently Wannabe doesn't ever change the cursor, so we don't actually need
  80. ** these referenced here.  However, since Wannabe is supposed to be an application
  81. ** in progress, it is very likely that you will need to reference these as your
  82. ** project develops.  See DTS.StyleChat and DTS.Draw for examples of setting the cursor. */
  83.  
  84. /* Some cursors are pointer-based, and some cursors are resource-based.
  85. ** If a cursor is resource-based, it needs to be loaded and made to not move,
  86. ** and then gCursorPtr can be set to point to it.  This makes all cursors
  87. ** pointer-based.  Also, gCursorPtr is used by DTS.Lib..framework to
  88. ** determine if there is a current cursor.  If gCursorPtr is nil, then
  89. ** there is no current cursor, and the cursor has to be recalculated, no
  90. ** matter where the mouse is.  If gCursorPtr is not nil, then if the
  91. ** mouse position is within the cursor region gCursorRgn, the cursor is
  92. ** correct, and no recalculation is necessary.  If it is outside this region,
  93. ** then it is recalculated.  What does this all mean?  It means that if you
  94. ** want to guarantee that the cursor is recalculated next time DoWindowCursor()
  95. ** is called, set gCursorPtr to nil.
  96. **
  97. ** If you have a cursor resource, you need to:
  98. ** 1) Load the resource.
  99. ** 2) Make a fixed copy of it.
  100. ** 3) Set the cursor to it.
  101. ** 4) Set gCursorPtr to point to the fixed copy.
  102. **
  103. ** There is a function that does almost all of this, called DoSetResCursor().
  104. ** It does all but set gCursorPtr to it.  (It actually sets gCursorPtr to nil.)
  105. ** It does return a pointer to the permanent copy, so typically what you will
  106. ** want to do is the following:
  107. **     gCursorPtr = DoSetResCursor(theCursorID);
  108. **
  109. ** So why set gCursorPtr to nil as the default action?  This allows you to
  110. ** set a temporary cursor, which will be replaced when DoWindowCursor() is
  111. ** called next, or it allows you to set a cursor that maps to the cursor
  112. ** region gCursorRgn (by setting gCursorPtr to the return result). */
  113.  
  114.  
  115.  
  116. /*****************************************************************************/
  117. /*****************************************************************************/
  118.  
  119. #ifdef applec
  120. #pragma segment Window
  121. #endif
  122.  
  123. /*****************************************************************************/
  124. /*****************************************************************************/
  125.  
  126.  
  127.  
  128. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  129.  
  130. /* Calculate application specific frame area (Called by DoCalcFrameRgn).
  131. ** You are passed an empty region.  You are supposed to add any custom frame
  132. ** parts that this document uses.  Typically there are no frame portions, as
  133. ** they are accounted for in other ways.  The scrollbars and grow icon will
  134. ** automatically be contributed to the calculation of the frame region.
  135. ** If you use sidebars, these are also added in automatically.  This is only
  136. ** used if the frame region is more complicated than can automatically be
  137. ** handled.  So, almost always, you will simply leave the region empty. */
  138.  
  139. void    CalcFrameRgn(FileRecHndl frHndl, WindowPtr window, RgnHandle rgn)
  140. {
  141. #ifndef __MWERKS__
  142. #pragma unused (frHndl, window, rgn)
  143. #endif
  144. }
  145.  
  146.  
  147.  
  148. /*****************************************************************************/
  149.  
  150.  
  151.  
  152. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  153.  
  154. /* This is called (by DoContentClick()) when a mouse-down event occurs in the content of
  155. ** a window.  Other applications might want to call FindControl, TEClick, etc., to
  156. ** further process the click. */
  157.  
  158. void    ContentClick(WindowPtr window, EventRecord *event, Boolean firstClick)
  159. {
  160. #ifndef __MWERKS__
  161. #pragma unused (firstClick)
  162. #endif
  163.  
  164.     ControlHandle    ctl;
  165.     short            action, cnum;
  166.  
  167.     cnum = IsCtlEvent(window, event, &ctl, &action);
  168.         /* That was easy.  Scrolling was just handled.  Other stuff would be handled
  169.         ** by IsCtlEvent, if we had other stuff to do.  We don't have any other
  170.         ** controls in the content besides the document scrollbars. */
  171.  
  172.     return;
  173. }
  174.  
  175.  
  176.  
  177. /*****************************************************************************/
  178.  
  179.  
  180.  
  181. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  182.  
  183. /* DoKeyDown() is first called by the application.  Then if the key isn't a menu
  184. ** key, DoKeyDown() calls this code.  Here are the rules for this function:
  185. **
  186. ** 1) If you handle the key, return(true).  This completes the key handling.
  187. ** 2) If you don't handle the key, you return false.  However, there are two
  188. **    situations for not handling the key:
  189. **      a) You want someone else to.
  190. **      b) You want nobody else to look at the key.
  191. **    This is what the boolean passThrough is for.  If you wish the next window
  192. **    to have a look at the key, set the boolean passThrough to true.  passThrough
  193. **    is already initialized to false, which is the common case, so you only have
  194. **    to worry about setting it true.
  195. **
  196. ** If you have a window that never processes keys and always passes them through,
  197. ** just set the contentKeyProc to nil.  This will indicate to the application
  198. ** framework that all keys should be passed through this window.  DTS.Draw has
  199. ** such a window.  Its palette window doesn't accept keys.  They are passed through
  200. ** to document windows. */
  201.  
  202. Boolean    ContentKey(WindowPtr window, EventRecord *event, Boolean *passThrough)
  203. {
  204. #ifndef __MWERKS__
  205. #pragma unused (passThrough)
  206. #endif
  207.  
  208.     short    cnum;
  209.  
  210.     cnum = IsCtlEvent(window, event, nil, nil);
  211.         /* See DTS.Draw for an example of what you might do here. */
  212.  
  213.     return(true);
  214. }
  215.  
  216.  
  217.  
  218. /*****************************************************************************/
  219.  
  220.  
  221.  
  222. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  223.  
  224. /* Draw application specific content (Called by DoDrawFrame).
  225. **
  226. ** If your application has any custom frame areas, or if it uses sidebars,
  227. ** this is the function that you would put the frame drawing code.  The
  228. ** document scrollbars and grow icon drawing is handled by DTS.framework.
  229. ** Just do the sidebar and custom areas here. */
  230.  
  231. void    DrawFrame(FileRecHndl frHndl, WindowPtr window, Boolean activate)
  232. {
  233.     MoveTo(0, (*frHndl)->fileState.topSidebar - 1);
  234.     LineTo((*frHndl)->fileState.leftSidebar - 1 - 16384, (*frHndl)->fileState.topSidebar - 1);
  235.     LineTo((*frHndl)->fileState.leftSidebar - 1 - 16384, 16383);
  236.  
  237.     BeginFrame(window);
  238.     DoDrawControls(window, activate);
  239.     EndFrame(window);
  240. }
  241.  
  242.  
  243.  
  244. /*****************************************************************************/
  245.  
  246.  
  247.  
  248. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  249.  
  250. /* Frees up any application-specific memory in the document.  This is called by
  251. ** DoFreeDocument, which is called by DisposeDocument().  The application would
  252. ** call DisposeDocument(), not DoFreeDocument() or FreeDocument() directly.
  253. **
  254. ** The document may have a bunch of handles off the main handle of the document.
  255. ** This is where they are freed.  DisposeDocument calls this prior to releasing
  256. ** the ram for the main handle of the document, so release everything else
  257. ** here, or you will have a memory leak.
  258. **
  259. ** NOTE:  Calling DefaultFreeDocument() frees up all memory used by a
  260. ** hierarchical document (see TreeObj package). */
  261.  
  262. OSErr    FreeDocument(FileRecHndl frHndl)
  263. {
  264.     return(DefaultFreeDocument(frHndl));
  265. }
  266.  
  267.  
  268.  
  269. /*****************************************************************************/
  270.  
  271.  
  272.  
  273. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  274.  
  275. /* Any additional window disposal tasks can be handled here. */
  276.  
  277. OSErr    FreeWindow(FileRecHndl frHndl, WindowPtr window)
  278. {
  279. #ifndef __MWERKS__
  280. #pragma unused (window)
  281. #endif
  282.  
  283.     WindowPtr    ww;
  284.     FileRecHndl    ff;
  285.  
  286.     if ((*frHndl)->fileState.sfType == kDocFileType) {
  287.         for (ww = nil; (ww = GetNextWindow(ww, 0)) != nil;) {
  288.             ff = (FileRecHndl)GetWRefCon(ww);
  289.             if ((*ff)->fileState.sfType == kViewHierFileType) {
  290.                 if ((*frHndl)->d.doc.root == (*ff)->d.doc.root) {
  291.                     DisposeOneWindow(ww, kClose);
  292.                     ww = nil;
  293.                 }
  294.             }
  295.         }
  296.     }
  297.  
  298.     return(noErr);
  299. }
  300.  
  301.  
  302.  
  303. /*****************************************************************************/
  304.  
  305.  
  306.  
  307. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  308.  
  309. /* Image the document into the current port.
  310. **
  311. ** The only thing tricky about this function is that it needs to key off of
  312. ** the global variable gPrintPage.  gPrintPage is the current page that is
  313. ** being printed.  If gPrintPage is 0, then you are drawing to the window.
  314. **
  315. ** For when printing:
  316. **
  317. ** If gPrintPage is non-0, that is the page to be printed.  If after imaging
  318. ** the page there are no more pages, you should set gPrintPage to 0.  This
  319. ** indicates to the print loop that the end of the document has been reached.
  320. ** Even if the user indicated in the job dialog to print more pages, setting
  321. ** gPrintPage to 0 states that the last page has been printed.  This is necessary
  322. ** because the print loop can't know when printing is done.  The imaging procedure
  323. ** is the logical one to state when everything has been imaged. */
  324.  
  325. OSErr    ImageDocument(FileRecHndl frHndl)
  326. {
  327. #ifndef __MWERKS__
  328. #pragma unused (frHndl)
  329. #endif
  330.  
  331.     WindowPtr    curPort;
  332.  
  333.     GetPort(&curPort);
  334.     if (!gPrintPage) {                                    /* If not printing... */
  335.         DoDrawControls(curPort, false);                    /* Draw the content controls. */
  336.     }
  337.     gPrintPage = 0;
  338.  
  339.     return(noErr);
  340. }
  341.  
  342.  
  343.  
  344. /*****************************************************************************/
  345.  
  346.  
  347.  
  348. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  349.  
  350. /* This function does the remaining window initialization.
  351. **
  352. ** There may be additional content initialization for the window.  At this point,
  353. ** you have a window, but it is currently invisible.  If you return noErr, then
  354. ** the window will be set to the state indicated for that window.  Why this function?
  355. ** You may wish to add controls to the content of the window.  You may have a
  356. ** TextEdit record in the content.  All of these sort of things can't be created
  357. ** until there is a window to contain them.  First a document is read in, and then
  358. ** if the document creation succeeds, a window is created for that document.
  359. ** At this point we have a document, and we are on our way to having a window.
  360. ** All that remains is any additional content initialization.  Do it, return
  361. ** noErr, and everybody's happy.  If something goes wrong here, return the error,
  362. ** and the incomplete window will be disposed of. */
  363.  
  364. OSErr    InitContent(FileRecHndl frHndl, WindowPtr window)
  365. {
  366.     OSErr    err;
  367.  
  368.     err = AddControlSet(window, (*frHndl)->fileState.sfType, kwStandardVis, 0, 0, nil);
  369.     return(err);
  370. }
  371.  
  372.  
  373.  
  374. /*****************************************************************************/
  375.  
  376.  
  377.  
  378. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  379.  
  380. /* The code below assumes that you are using the hierarchical document package.
  381. ** If you are, the entire hierarchical document is read in with just these two
  382. ** calls.  If you don't use it, you are on your own.  See DTS.StyleChat for an
  383. ** example of an application that uses the DTS.framework without the hierarchical
  384. ** document package. */
  385.  
  386. OSErr    ReadDocument(FileRecHndl frHndl)
  387. {
  388.     OSErr    err;
  389.  
  390.     err = DefaultReadDocument(frHndl);
  391.     if (!err)
  392.         DefaultReadDocumentFixup(frHndl);
  393.  
  394.     return(err);
  395. }
  396.  
  397.  
  398.  
  399. /*****************************************************************************/
  400.  
  401.  
  402.  
  403. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  404.  
  405. /* Resize application specific content (Called by ResizeWindow).
  406. **
  407. ** This gets called when a user does a zoom or window resizing operation.
  408. ** It is possible that things in the content need to be resized in conjunction
  409. ** with the resizing of the window. */
  410.  
  411. void    ResizeContent(WindowPtr window, short oldh, short oldv)
  412. {
  413. #ifndef __MWERKS__
  414. #pragma unused (window, oldh, oldv)
  415. #endif
  416.  
  417.     /* See DTS.StyleChat for a sample usage of this function. */
  418. }
  419.  
  420.  
  421.  
  422. /*****************************************************************************/
  423.  
  424.  
  425.  
  426. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  427.  
  428. /* Scroll application specific frame (Called by DoScrollFrame).
  429. **
  430. ** Some applications may need to scroll the "frame" of the document along
  431. ** with the document contents.  This is common for applications with rulers,
  432. ** or other similar sidebar items. */
  433.  
  434. void    ScrollFrame(FileRecHndl frHndl, WindowPtr window, long dh, long dv)
  435. {
  436. #ifndef __MWERKS__
  437. #pragma unused (frHndl, window, dh, dv)
  438. #endif
  439. }
  440.  
  441.  
  442.  
  443. /*****************************************************************************/
  444.  
  445.  
  446.  
  447. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  448.  
  449. /* Since the hierarchical document package isn't used by DTS.StyleChat,
  450. ** this function actually never gets called. */
  451.  
  452. void    UndoFixup(FileRecHndl frHndl, Point contOrg, Boolean afterUndo)
  453. {
  454. #ifndef __MWERKS__
  455. #pragma unused (frHndl, contOrg, afterUndo)
  456. #endif
  457.  
  458.     /* See DTS.Draw for an example of what you might do here. */
  459. }
  460.  
  461.  
  462.  
  463. /*****************************************************************************/
  464.  
  465.  
  466.  
  467. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  468.  
  469. /* This function is where you adjust the cursor to reflect the location in the
  470. ** document or window.  You have the additional input of gCursorRgn to deal
  471. ** with.  The way that the cursor handling works is as follows:
  472. ** 1) The application calls DoWindowCursor().
  473. ** 2) DoWindowCursor() works its way through the windows/documents, front to back.
  474. **    It looks at the document's windowCursorProc and checks to see if the document
  475. **    has one.  If the document doesn't have one, then it assumes that that window
  476. **    always wants an arrow.  If the cursor is over that window, the cursor is set
  477. **    to an arrow, and we're done.  If the cursor isn't over the window, then the next
  478. **    window is tried.  If all documents don't have a windowCursorProc, then the cursor
  479. **    is set to an arrow (for the non-document area of the screen).
  480. ** 3) If a document has a windowCursorProc, then the proc is called.  The proc's
  481. **    job is as follows:
  482. **    a) If the cursor is over a position that is determined by the window, then
  483. **       the proc removes other areas from gCursorRgn.  Note that it should not
  484. **       simply set the area to what it "thinks" is the correct area.  This window
  485. **       may not be the front-most.  Other windows will have already been subtracted
  486. **       from gCursorRgn.  The resultant gCursorRgn is the correct cursor area,
  487. **       and should be passed to WaitNextEvent calls in the application (already the case
  488. **       in EventLoop.c).  Also, the cursor should be set to the correct cursor, of course.
  489. **       You should also return true, as the cursor has been determined.
  490. **    b) If the cursor is not over a position for this window, then you should
  491. **       return.  You will either pass back true or false.  If you don't wish
  492. **       windows behind this window to have a shot at cursor determination, then
  493. **       return true.  This states that the cursor is "determined".  It is, in the
  494. **       sense that no further determination will occur.  If you return false, then
  495. **       other windows get a shot at determining the cursor.
  496. **
  497. ** Setting the cursor to the correct cursor isn't as easy as you would expect.
  498. ** DTS.Lib..framework uses the global gCursorPtr as the reference to the cursor.  This is
  499. ** fine if the cursor is pointer-based, but if the cursor is resource-based, it is a bit
  500. ** more of a problem.  What you will need to do is to call DoSetResCursor() to make the
  501. ** resource cursor pointer-based.  DoSetResCursor() will set gCursorPtr to nil, and it
  502. ** also returns the pointer to the permanent copy of the cursor resource.  Just set gCursorPtr
  503. ** to the return result of DoSetResCursor(), and you will be set. */
  504.  
  505. Boolean    WindowCursor(FileRecHndl frHndl, WindowPtr window, Point globalPt)
  506. {
  507.     WindowPtr        oldPort;
  508.     RgnHandle        contRgn;
  509.     Rect            rr, teViewRct, contRct;
  510.     TEHandle        teHndl;
  511.     ControlHandle    viewCtl;
  512.     Point            contOrg;
  513.     CTEDataHndl        teData;
  514.     short            mode;
  515.  
  516.     if (!window) {
  517.         SetCursor(gCursorPtr = &qd.arrow);
  518.         return(true);
  519.     }
  520.  
  521.     oldPort = SetFilePort(frHndl);
  522.     window = (*frHndl)->fileState.window;
  523.  
  524.     GetContentOrigin(window, &contOrg);
  525.     SetOrigin(contOrg.h, contOrg.v);        /* Scroll position of window. */
  526.  
  527.     GetContentRect(window, &contRct);
  528.         /* This returns the content portion of the window in local coordinates,
  529.         ** less document scrollbar and sidebar areas. */
  530.  
  531.     contRgn = NewRgn();
  532.     for (viewCtl = nil; ((viewCtl = CTENext(window, &teHndl, viewCtl, 1, false)) != nil);) {
  533.         teViewRct = (*teHndl)->viewRect;
  534.         SectRect(&teViewRct, &contRct, &rr);
  535.         LocalToGlobalRect(&rr);
  536.         if ((*viewCtl)->contrlVis) {
  537.             if (!CTEReadOnly(teHndl)) {
  538.                 RectRgn(contRgn, &rr);
  539.                 teData = (CTEDataHndl)(*viewCtl)->contrlData;
  540.                 mode   = (*teData)->mode;
  541.                 if ((mode & cteActive) || (!(mode & cteTwoStep))) {
  542.                     if (PtInRect(globalPt, &rr)) {
  543.                         gCursorPtr = DoSetResCursor(iBeamCursor);
  544.                         SectRgn(gCursorRgn, contRgn, gCursorRgn);
  545.                         DisposeRgn(contRgn);
  546.                         SetPort(oldPort);
  547.                         return(true);
  548.                     }
  549.                 }
  550.                 DiffRgn(gCursorRgn, contRgn, gCursorRgn);
  551.             }
  552.         }
  553.     }
  554.     SetCursor(gCursorPtr = &qd.arrow);
  555.     DisposeRgn(contRgn);
  556.     return(true);
  557. }
  558.  
  559.  
  560.  
  561. /*****************************************************************************/
  562.  
  563.  
  564.  
  565. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  566.  
  567. /* After the DTS.Lib framework disposes of a window, it calls here.  This is
  568. ** to give the application a chance to do any additional tasks related to
  569. ** a window closing.  DTS.StyleChat doesn't have anything else extra to do. */
  570.  
  571. void    WindowGoneFixup(WindowPtr window)
  572. {
  573. #ifndef __MWERKS__
  574. #pragma unused (window)
  575. #endif
  576. }
  577.  
  578.  
  579.  
  580. /*****************************************************************************/
  581.  
  582.  
  583.  
  584. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  585.  
  586. /* The reverse function of ReadDocument. */
  587.  
  588. OSErr    WriteDocument(FileRecHndl frHndl)
  589. {
  590.     return(DefaultWriteDocument(frHndl));
  591. }
  592.  
  593.  
  594.  
  595. /*****************************************************************************/
  596.  
  597.  
  598.  
  599. /* •• You don't call this.  DTS.Lib..framework does at open-application time. •• */
  600.  
  601. OSErr    DoOpenApplication(void)
  602. {
  603.     return(noErr);
  604. }
  605.  
  606.  
  607.  
  608. /*****************************************************************************/
  609. /*****************************************************************************/
  610. /*****************************************************************************/
  611.  
  612.  
  613.  
  614. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  615.  
  616. Boolean    AdjustMenuItems(WindowPtr window, short menuID)
  617. {
  618.     Boolean        redrawMenuBar;
  619.     MenuHandle    menu;
  620.  
  621.     redrawMenuBar = false;
  622.  
  623.     switch (menuID) {
  624.         case mFile:
  625.             redrawMenuBar = DoAdjustFileMenu(window);
  626.             break;
  627.         case mEdit:
  628.             redrawMenuBar = DoAdjustEditMenu(window);
  629.             break;
  630.         default:
  631.             menu = GetMenuHandle(menuID);
  632.             if (menu)
  633.                 (*menu)->enableFlags |= 0xFFFFFFFEL;
  634.             break;
  635.     }
  636.  
  637.     return(redrawMenuBar);
  638. }
  639.  
  640.  
  641.  
  642. /*****************************************************************************/
  643.  
  644.  
  645.  
  646. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  647.  
  648. Boolean    DoMenuItem(WindowPtr window, short menuID, short menuItem)
  649. {
  650. #ifndef __MWERKS__
  651. #pragma unused (window)
  652. #endif
  653.  
  654.     return(DoMenuCommand(menuID, menuItem));
  655. }
  656.  
  657.  
  658.  
  659.